(function() {

	var UserCon = require("../../core/user/_con");
	var db = require("../../core/db/index");
	var config = require("../../core/_include/config");
	var ResponObj = require("../_include/responObj");
	var helper = require("../../core/_include/helper");
	var role = require("./role");

	module.exports = {
		prefix: "/user/bina",
		get: {
			"/all": function() {
				var user = role.getUser(this);
				var bina_map = user.getBinaBus();
				this.body = ResponObj("json", bina_map);
			},
			"/by_bus_id": function() {
				var user = role.getUser(this);
				var bus_id = this.request.query.bus_id;
				if (!bus_id) {
					throwCusError("参数错误")
				}
				this.body = ResponObj("json", user.getBinaBusByBusId(bus_id));
			},
			"/first_acc_users/:bus_id": function() {
				var user = role.getUser(this);
				var bus_id = this.params.bus_id;
				this.body = ResponObj("json", user.getBinaFirstAccUsersByBusId(bus_id));
			}
		},
		put: {
			"/未申请兑换_to_申请兑换中": function() {
				var user = role.getUser(this);
				var body = this.request.body;
				var bus_id = body.bus_id;
				if (!bus_id) {
					throwCusError("参数错误");
				}
				user.bina_未申请兑换_to_申请兑换中(bus_id);
				var bus_bina_info = user.getBinaBusByBusId(bus_id);
				this.body = ResponObj("json", bus_bina_info);
			},
			"/商家已付款_to_用户确认付款": function() {
				var user = role.getUser(this);
				var body = this.request.body;
				var bus_id = body.bus_id;
				if (!bus_id) {
					throwCusError("参数错误");
				}
				user.bina_商家已付款_to_用户确认付款(bus_id);
				var bus_bina_info = user.getBinaBusByBusId(bus_id);
				this.body = ResponObj("json", bus_bina_info);
			},
			"/to_bususer_money": function() {
				var user = role.getUser(this);
				var bus_id = this.request.body.bus_id;
				var money = this.request.body.money;
				if (!(bus_id && money)) {
					throwCusError("参数错误")
				}
				var bus_bina_info = user.bina_to_BusUser_money(bus_id, money);
				this.body = ResponObj("json", bus_bina_info);
			}
		}
	}

}());